﻿using System.Collections.Generic;

namespace FunctionalProgramming.PatternMatching
{
   /// <summary>
   /// Encapsulates pattern matching.
   /// </summary>
   public static class PatternMatcher
   {
      /// <summary>
      /// Starts pattern matching that will result in transformation of provided input value.
      /// </summary>
      /// <typeparam name="TIn">The type of the input.</typeparam>
      /// <typeparam name="TOut">The type of the output.</typeparam>
      /// <param name="input">The input.</param>
      /// <returns>Transfomration pattern matching job.</returns>
      public static TransformationJob<TIn, TOut> Transform<TIn, TOut>(TIn input)
      {
         return new TransformationJob<TIn, TOut>(input);
      }

      /// <summary>
      /// Starts pattern matching that will result in matching of collection.
      /// </summary>
      /// <typeparam name="T">Type of elements of collection to match.</typeparam>
      /// <param name="collectionToMatch">The collection to match.</param>
      /// <returns>Collection pattern matching job.</returns>
      public static CollectionMatchingJob<T> MatchCollection<T>(IEnumerable<T> collectionToMatch)
      {
         return new CollectionMatchingJob<T>(collectionToMatch);
      }
   }
}